package com.bestattempt.utility.bind.initializers;

import java.lang.reflect.Field;

/**
 * TODO: Document me
 *
 * @author Ganeshji Marwaha
 * @since Oct 14, 2006
 */
public interface Initializer {
    /**
     * Implementation should instantiate the field and set it in the given object and return the initialized object.
     *
     * @param toInitialize - The object to be initialized
     * @param toInstantiate - The field to be instantiated depending on the current path being traversed.
     * @return Initialized Object.
     */
    public Object initialize(Object toInitialize, Field toInstantiate);

    /**
     * Implementation should initialize a particular type of Collection field with the supplied index.
     * If the Collection is not parameterized, and thus cant find which class to instantiate and store, then the
     * implementation should throw <code>InitializationException</code>
     * If the parameterized type is found, then the parameterized type should be instantiated and set on the
     * collection in the given index.
     *
     * @param toInitialize - The object to be initialized
     * @param toInstantiate - The field to be instantiated depending on the current path being traversed.
     * @param index - Index of the collection that has to be instantiated
     * @return Initialized Object.
     */
    public Object initialize(Object toInitialize, Field toInstantiate, String index);
}
